#include <system.h>
#include <std.h>
#include <pio.h>
#include <error.h>
#include <pipe.h>
#include <gserv.h>
#include <type.h>

void cl()
{
	unsigned long i;
	u8 *db;
	char *commands[]={"reboot","halt","help","clear","dir","show","list","root"};
	char *cmd,*opt;
	cmd=(char *)get_mem(200);
	opt=(char *)get_mem(50);
	while(1)	{
		printf("\n:)");
		gets(cmd);
		if(strcmp(cmd,commands[0])==NULL)	{
			reboot();
		}
		else if(strcmp(cmd,commands[1])==NULL)	{
			halt(0);
		}
		else if(strcmp(cmd,commands[2])==NULL)	{
			printf("Commands:");
			for(i=0;i<8;i++)	{
				printf(" %s",commands[i]);
			}
		}
		else if(strcmp(cmd,commands[3])==NULL)	{
			clrscr();
		}
		else if(strncmp(cmd,commands[4],3)==NULL)	{
			getstringparameter(cmd,opt,' ',1);
			go_entry(opt);
		}
		else if(strcmp(cmd,commands[5])==NULL)	{
			show_dir();
		}
		else if(strcmp(cmd,commands[6])==NULL)	{
			list_entries();
		}
		else if(strcmp(cmd,commands[7])==NULL)	{
			root();
		}
		else	{
			printf("Unrecognized command");
		}
	}
}
